package com.meichis.yndms.vm;

import android.util.ArrayMap;

import androidx.lifecycle.MutableLiveData;

import com.meichis.yndms.model.BusinessBoard;
import com.meichis.yndms.repository.manager.BusinessBoardManager;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2022-05-17 16:23
 */
public class ProductStockVM extends MyViewModel {

    //接口请求的所有数据
    private MutableLiveData<List<BusinessBoard>> allDatas;
    //刷选后保存当前所包含的仓库
    private MutableLiveData<ArrayList<BusinessBoard>> businessBoardList;
    //用户选择的仓库
    private MutableLiveData<BusinessBoard> businessBoard;
    //仓库---该仓库的所有数据
    private MutableLiveData<Map<BusinessBoard,List<BusinessBoard>>> mapBusinessBoard;

    public MutableLiveData<Map<BusinessBoard, List<BusinessBoard>>> getMapBusinessBoard() {
        if (mapBusinessBoard == null){
            mapBusinessBoard = new MutableLiveData<>();
            mapBusinessBoard.setValue(new ArrayMap<>());
        }
        return mapBusinessBoard;
    }

    public MutableLiveData<List<BusinessBoard>> getAllDatas() {
        if (allDatas == null){
            allDatas = new MutableLiveData<>();
        }
        return allDatas;
    }

    public MutableLiveData<ArrayList<BusinessBoard>> getBusinessBoardList() {
        if (businessBoardList == null){
            businessBoardList = new MutableLiveData<>();
            businessBoardList.setValue(new ArrayList<>());
        }
        return businessBoardList;
    }

    public MutableLiveData<BusinessBoard> getBusinessBoard() {
        if (businessBoard == null){
            businessBoard = new MutableLiveData<>();
        }
        return businessBoard;
    }

    public void getMonthProductSalesSummaryByBrand() {
        BusinessBoardManager.getInstance().getMonthProductStandingByBrand(getShowDialog(),
                getUserInfo().getValue().getOrgId(), getUserInfo().getValue().getId(), getAllDatas());
    }
}
